﻿/*
* Copyright (c) 2010-2012 Tesla Engine Group
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/


using System;
using System.Collections.Generic;

namespace Tesla.Content.Loaders.Model.Dxs {
    public class DxsNode {
        protected String _name;
        protected List<DxsNode> _children;
        protected DxsNode _parent;

        public String Name {
            get {
                return _name;
            }
            set {
                _name = value;
            }
        }

        public List<DxsNode> Children {
            get {
                return _children;
            }
        }

        public DxsNode Parent {
            get {
                return _parent;
            }
            set {
                _parent = value;
            }
        }

        public DxsNode(String name) {
            _name = name;
            _children = new List<DxsNode>();
        }

        public void AddChild(DxsNode node) {
            _children.Add(node);
            node.Parent = this;
        }

        public void RemoveChild(String name) {
            DxsNode node = null;
            for(int i = 0; i < _children.Count; i++) {
                if(_children[i].Name.Equals(name)) {
                    node = _children[i];
                    break;
                }
            }
            if(node != null) {
                node.Parent = null;
                _children.Remove(node);
            }
        }
    }
}
